import pandas as pd
from sqlalchemy import create_engine
# 连接到MySQL数据库
conn = create_engine('mysql+mysqldb://root:123@localhost:3306/z_sproot_series?charset=utf8')


# 读取Excel文件
excel_file = '../../../zz_download_file/rzrq/2024-01-02.xlsx'
df = pd.read_excel(excel_file)

# 将数据写入MySQL表
table_name = 'stock_rzrq'
df.to_sql(table_name, conn, if_exists='replace', index=False)

# 关闭数据库连接
conn.close()